
version 15
capture log close
set more off
clear
clear matrix
clear mata

if c(username)=="WB485280" {
		glo rootdir		"C:\Users\wb485280\OneDrive - WBG\radicalization"
		}
if c(username)=="WB382635" {
		glo rootdir		"C:\Users\wb382635\Dropbox\Unemp & daesh"
		}
if c(username)=="WB452275" {
		glo rootdir		"C:\Users\WB452275\Dropbox\Projects\Unemp & daesh"
		}
if c(username)=="sarurchaudhary" {
		glo rootdir		"/Users/sarurchaudhary/Dropbox/Unemp & daesh"
		}
if c(username)=="kartikabhatia" {
			glo rootdir		"/Users/kartikabhatia/Dropbox/Before2019/Unemp & daesh"
			}
			
		glo	datadir     "${rootdir}/Data/Raw data"
		glo outdir		"${rootdir}/Data/Working datasets"
		glo dodir		"${rootdir}/Dofiles"
        
		cd "${outdir}"
		
		
	    log using gallup_prep, replace t


* ------------------------------------------------------------------------------
* Date : July 2017 [chkd oct 2021]


* Project : Mena Economic Monitor, Fall 2016 edition (MNACE, The World Bank)


* This do file prepares the Gallup database for merge

* Database used : The_Gallup_032516.dta.dta


* Output : gallup.dta

* ------------------------------------------------------------------------------



*                      ---------------------------
*                      --------GALLUP Data--------
*                      ---------------------------


use "${datadir}/The_Gallup_032516.dta", clear
rename WP* wp*

*           =================
*           Variables to keep
*           =================


* Generate region dummies
tab REG2_GLOBAL, gen(region)

********************************************
*           Radicalization Variables
********************************************

/*Variable wp941: I would like you to indicate to which extent it can be morally 
justified. Other attacks in which civilians are the target. 

   1 "1 Cannot be justified at all"
   2 "2"
   3 "3"
   4 "4"
   5 "5 Completely justifiable"
   6 "6 (DK)"
   7 "7 (Refused)" */
recode wp941 (6=.a) (7 =.d) 
tab wp941, gen(g_civ1_viol)

/*WP940 There are many acts some people
may do in life. I will read out to you a
number of these acts. I would like you to
indicate to which extent it can be morally
justified. Events of Sept 11th in USA, that is,
the attack on the World Trade
   1 "1 Cannot be justified at all"
   2 "2"
   3 "3"
   4 "4"
   5 "5 Completely justifiable"
   6 "6 (DK)"
   7 "7 (Refused)"; */
recode wp940 (6=.a) (7 =.d)
tab wp940, gen(g_wtc_usa) 

 /*Variable wp938: I would like you to indicate to which extent it can be morally
justified. Sacrificing ones life for what one believes in.

   1 "1 Cannot be justified at all"
   2 "2"
   3 "3"
   4 "4"
   5 "5 Completely justifiable"
   6 "6 (DK)"
   7 "7 (Refused)" */  
   
recode wp938 (6=.a) (7 =.d)
tab wp938, gen(g_sacr_life)  

/* WP11356 Please tell me whether you agree or disagree with the following 
statements: You are willing to take any amount of extreme risk to get
what you want.
   1 "1 Agree"
   2 "2 Disagree"
   3 "3 (DK)"
   4 "4 (Refused)"; */
 
recode wp11356 (3=.a) (4 =.d)
tab wp11356, gen(g_extreme_risk)  
  
/* WP12412 Can oppressed groups improve
their situation through peaceful means
alone, or can oppressed groups NOT
improve their situation through peaceful
means alone?
   1 "1 Yes, peaceful means ALONE will work"
   2 "2 No, peaceful means ALONE will not work"
   3 "3 (DK)"
   4 "4 (Refused)"; */
   
recode wp12412 (3=.a) (4 =.d)
tab wp12412, gen(g_peaceful1_means)  

 /*WP4653 Some people think that For the
military to target and kill civilians is
sometimes justified, while others think that
kind of violence is never justified. Which is
your opinion?
   1 "1 Never justified"
   2 "2 Sometimes justified"
   3 "3 (Depends)"
   4 "4 (DK)"
   5 "5 (Refused)"; */
   
recode wp4653 (4=.a) (5 =.d)
tab wp4653, gen(g_mil_target_civ)
   
/*WP4654 Some people think that __________.
Which is your opinion? For an individual or
a small group to target and kill civilians is
sometimes justified, while others think that
kind of violence is never justified
     1 "1 Never justified"
   2 "2 Sometimes justified"
   3 "3 (Depends)"
   4 "4 (DK)"
   5 "5 (Refused)"; */

recode wp4654 (4=.a) (5=.d)
tab wp4654, gen(g_civ2_viol)
  
  /*WP4655 Some people believe that groups
that are oppressed and are suffering from
injustice can improve their situation by
peaceful means ALONE. Others do not
believe that peaceful means ALONE will
work to improve the situation for such
oppre
   1 "1 Peaceful means ALONE will work"
   2 "2 Peaceful means ALONE will NOT work"
   3 "3 (DK)"
   4 "4 (Refused)"; */
 
recode wp4655 (3=.a) (4 =.d) (5=.)
tab wp4655, gen(g_peaceful2_means)  

   
 /*WP936 There are many acts some people
may do in life. I will read out to you a
number of these acts. I would like you to
indicate to which extent it can be morally
justified. Not living in harmony with those
who do not share your opinion or v  
      1 "1 Cannot be justified at all"
   2 "2"
   3 "3"
   4 "4"
   5 "5 Completely justifiable"
   6 "6 (DK)"
   7 "7 (Refused)"; */
 
 recode wp936 (6=.a) (7=.d)
 tab wp936, gen(g_living_harmony) 

 
********************************************
*        Demographic Variables
********************************************

/*WP1219 Gender
 1 "1 male"
   2 "2 female" */
tab wp1219, gen(g_gender)


***Age

*WP1220 AGE: Please tell me your age.


*recode wp1220 (100=.d) // 100 is code for refused
*egen agecat1 = cut(wp1220), at(12,25,65,102) icodes //youths (13-24) adults (25-64) old (65+)
*label define ff 0 "youth (13-24)" 1 "adult (25-64)" 2 "old (65+)"
*label values agecat1 ff
*tab agecat1, gen(g_age_cat)


***Income

codebook INC_007 // per capita income

* Individuals living on less than 2$ a day
/* 0 more than 2$
   1 less than 2$ */
tab INC_011, gen(g_poverty)   

* HH income within country quintiles
/* 1 "1 Poorest 20%"
   2 "2 Second 20%"
   3 "3 Middle 20%"
   4 "4 Fourth 20%"
   5 "5 Richest 20%"; */
*tab INC_004, gen(g_income_quintiles)  


***Urban

/*WP14 Respondent lives in:
   1 "1 A rural area or on a farm"
   2 "2 A small town or village"
   3 "3 A large city"
   4 "4 (DK)"
   5 "5 (Refused)"
   6 "6 A suburb of a large city"; */

recode wp14 (4=.a) (5 =.d)  (6=4)
label define pp 1 "rural area/farm" 2 "small town" 3 "large city" 4 "suburb"
label values wp14 pp
tab wp14, gen(g_residence)


***Marital Status

/*WP1223 What is your current marital status?
   1 "1 Single/Never been married"
   2 "2 Married"
   3 "3 Separated"
   4 "4 Divorced"
   5 "5 Widowed"
   6 "6 (DK)"
   7 "7 (Refused)"
   8 "8 Domestic partner"; */

recode wp1223 (6=.a) (7=.d)
tab wp1223, gen(g_marital_status)
  
    
  
/* children under 15 living in hh (yes/no) */
recode wp1230Recoded   (98=.a) (99=.d) 
tab wp1230Recoded , gen(g_children)


***Religion

/* WP119 Is religion an important part of your daily life?
   1 "1 Yes"
   2 "2 No"
   3 "3 (DK)"
   4 "4 (Refused)"; */
  
recode wp119 (3=.a) (4=.d)  
tab wp119, gen(g_religiosity)

recode wp1233Recoded (8=.) //one's religion
tab wp1233Recoded, gen (g_religion)

/* WP142 In ##COUNTRY##, do you have
confidence in each of the following, or not?
How about Religious organizations
(churches, mosques, temples, etc.)?
     1 "1 Yes"
   2 "2 No"
   3 "3 (DK)"
   4 "4 (Refused)"; */
recode wp142(3=.a) (4=.d)  
tab wp142, gen(g_conf_relg_org)
   
***Employment

   /*1 "1 Employed full time for an employer"
   2 "2 Employed full time for self"
   3 "3 Employed part time do not want full time"
   4 "4 Unemployed"
   5 "5 Employed part time want full time"
   6 "6 Out of workforce";*/
   
label define pt 1 "full time"  2 "self-employed" 3 "part-time" 4 "unemployed" 5 "underemployed" 6"outofwork"
label values EMP_2010 pt

tab EMP_2010, gen(g_emp_status)

***Education

/*wp3117. What is your highest completed level of education?
 1 "1 Completed elementary education or less (up to 8 years of basic education)"
   2 "2 Secondary - 3 year Secondary education and some education beyond secondary education (9-15 years of educat"
   3 "3 Completed four years of education beyond high school and/or received a 4-year college degree."
   4 "4 (DK)"
   5 "5 (RF)";*/

recode wp3117 (4=.a) (5=.d)
label define ps 1 "primary" 2 "secondary" 3 "tertiary" 
label values wp3117 ps
tab wp3117, gen(g_educ_status)


****************************************
*          Life satisfaction
****************************************

/*On which step of the ladder would you say
you personally feel you stand at this time,
assuming that the higher the step the
better you feel about your life, and the
lower the step the worse you feel about it?
Which step comes closest to the way you
feel?

   0 "00 Worst possible life"
   1 "01"
   2 "02"
   3 "03"
   4 "04"
   5 "05"
   6 "06"
   7 "07"
   8 "08"
   9 "09"
  10 "10 Best possible life"
  98 "98 (DK)"
  99 "99 (Refused)"; */
  
recode wp16 (98=.a) (99=.d) (1=0) (2=0) (3=0) (4=0) (5=1) (6=1) (7=2) (8=2) (9=2) (10=2) 
label define pdp 0 "suffering" 1 "struggling" 2 "thriving" 
label values wp16 pdp
tab wp16, gen (g_lifesat_present)

 /*Just your best guess, on which step do you
think you will stand in the future, say about
five years from now?

   0 "00 Worst possible life"
   1 "01"
   2 "02"
   3 "03"
   4 "04"
   5 "05"
   6 "06"
   7 "07"
   8 "08"
   9 "09"
  10 "10 Best possible life"
  98 "98 (DK)"
  99 "99 (Refused)"; */
  
recode wp18 (98=.a) (99=.d) (1=0) (2=0) (3=0) (4=0) (5=1) (6=1)(7=1) (8=2) (9=2) (10=2) 
label define jps 0 "suffering" 1 "struggling" 2 "thriving" 
label values wp18 jps
tab wp18, gen(g_lifesat_future)

***************************************
*          law and order
***************************************

/*QUESTIONS
- In the city or area where you live, do you have confidence in the local police force? (WP112)
- Do you feel safe walking alone at night in the city or area where you live? (WP113)
- Within the last 12 months, have you had money or property stolen from you or another household member? (WP117)*/

recode wp112 (3=.a) (4=.d) 
tab wp112, gen(g_conf_police)
recode wp113 (3=.a) (4=.d) 
tab wp113, gen(g_safeatnight)
recode wp117 (3=.a) (4=.d) 
tab wp117, gen(g_theft)

******************************
*    Communication
******************************

/*
- Does your home have a landline telephone? (WP35)
- Does your home have a cellular phone? (WP3119)
- Does your home have television? (WP37)
- Does your home have access to the Internet? (WP39) */

recode wp35 (3=.a) (4=.d)
tab wp35, gen(g_landline)
recode wp3119 (3=.a) (4=.d)
tab wp3119, gen(g_mobile)
recode wp37 (3=.a) (4=.d)
tab wp37, gen(g_tv)
recode wp39 (3=.a) (4=.d) 
tab wp39, gen(g_internet)

/*wp10251: Do the media in this country have a lot of freedom, or not?*/
recode wp10251 (3=.a) (4=.d)
tab wp10251, gen(g_freedom_media)

***********************************************
*        Community attachment 
***********************************************

/*QUESTIONS
- Are you satisfied or dissatisfied with the city or area where you live? (WP83)
- In the next 12 months, are you likely or unlikely to move away from the city or area where you live? (WP85)
- Would you recommend the city or area where you live to a friend or associate as a place to live, or not? (WP86) */

recode wp83 (3=.a) (4=.d)
tab wp83, gen(g_com1_attach)
recode wp85 (3=.a) (4=.d) 
tab wp85, gen(g_com2_attach)
recode wp86 (3=.a) (4=.d)
tab wp86, gen(g_com3_attach)


***********************************************
*        Social well-being 
***********************************************


/*- If you were in trouble, do you have relatives or friends you can count on to
 help you whenever you need them, or not?(WP27)
- In the city or area where you live, are you satisfied or dissatisfied with the
 opportunities to meet people and make friends? (WP10248)*/

recode wp27 (3=.a) (4=.d)
tab wp27, gen(g_social1_wellbeing)
recode wp10248 (3=.a) (4=.d) 
tab wp10248, gen(g_social2_wellbeing)


***********************************************
*        Time with family and friends 
***********************************************

 /* WP12095 On an average day, roughly how
much time do you spend on the following
activities: __________? Time with family and
relatives
   1 "1 Spend no time"
   2 "2 Less than one hour"
   3 "3 1-2 hours"
   4 "4 3-5 hours"
   5 "5 6-8 hours"
   6 "6 9 hours or more"
   7 "7 (DK)"
   8 "8 (Refused)";  */
     
recode wp12095 (7=.a) (8=.d) 
tab wp12095 , gen(g_time_family)

  /* WP12096 On an average day, roughly how
much time do you spend on the following
activities: __________? Time with friends
   1 "1 Spend no time"
   2 "2 Less than one hour"
   3 "3 1-2 hours"
   4 "4 3-5 hours"
   5 "5 6-8 hours"
   6 "6 9 hours or more"
   7 "7 (DK)"
   8 "8 (Refused)";  */
      
recode wp12096 (7=.a) (8=.d) 
tab wp12096, gen(g_time_friends)


**********************************************************
*              National Institutions 
**********************************************************

/*
- Do you have confidence in each of the following, or not? How about the military? (WP137)
- Do you have confidence in each of the following, or not? How about the judicial system and courts? (WP138)
- Do you have confidence in each of the following, or not? How about the national government? (WP139)
- Do you have confidence in each of the following, or not? How about honesty of elections? (WP144)*/

recode wp137 (3=.a) (4=.d) 
tab wp137, gen(g_conf_military)
recode wp138 (3=.a) (4=.d)
tab wp138, gen(g_conf_court)
recode wp139 (3=.a) (4=.d)
tab wp139, gen(g_conf_gov)
recode wp144 (3=.a) (4=.d)
tab wp144, gen(g_conf_election)

**********************************************************
*               Agency
**********************************************************

/*wp134: In this country, are you satisfied or dissatisfied 
with your freedom to choose what you do with your life?
  
   1 "1 Satisfied"
   2 "2 Dissatisfied"
   3 "3 (DK)"
   4 "4 (Refused)"; */
 recode wp134 (3=.a) (4=.d)
 tab wp134, gen(g_freedom_life)   
 
 *********************************************************
 *             Community Basics
 *********************************************************
 
 /*Is the city or area where you live a good place or not a good place to live
 for racial and ethnic minorities? (WP103) */
recode wp103 (3=.a) (4=.d)
tab wp103, gen(g_good_minorities) 

/*Is the city or areas where you live a good place or not a good place to live
 for gay or lesbian people? (WP105) */
recode wp105 (3=.a) (4=.d)
tab wp105, gen(g_good_lgbt) 

/*Is the city or area where you live a good place or not a good place to live
 for immigrants from other countries? (WP106) */
recode wp106 (3=.a) (4=.d)
tab wp106, gen(g_good_immigrants) 

/*In the city or area where you live, are you satisfied or dissatisfied with 
the roads and highways? (WP92)*/
recode wp92 (3=.a) (4=.d)
tab wp92, gen(g_sat_roads) 

/*In the city or area where you live, are you satisfied or dissatisfied 
with the public transportation systems? (WP91)*/
 recode wp91 (3=.a) (4=.d)
 tab wp91, gen(g_sat_pubtrans) 

/*In your city or area where you live, are you satisfied or dissatisfied 
with the quality of air? (WP94)*/
recode wp94 (3=.a) (4=.d)
tab wp94, gen(g_sat_air) 

/*In your city or area where you live, are you satisfied or dissatisfied with 
the quality of water? (WP95)	 */
recode wp95 (3=.a) (4=.d)
tab wp95, gen(g_sat_water) 


/*In your city or area where you live, are you satisfied or dissatisfied with the 
availability of good affordable housing? (WP98)*/
recode wp98 (3=.a) (4=.d)
tab wp98, gen(g_sat_housing) 

/*- In the city or area where you live, are you satisfied or dissatisfied with 
the educational system or the schools? (WP93) */
 recode wp93 (3=.a) (4=.d)
 tab wp93, gen(g_sat_schools) 

/* In the city or area where you live, are you satisfied or dissatisfied with 
the availability of quality healthcare? (WP97) */
 recode wp97 (3=.a) (4=.d)
 tab wp97, gen(g_sat_healthcare) 

*************************************************
*       View on America and West
*************************************************

  /*WP14256 I will read out to you a set of
statements, which you may or may not
totally agree with. As I read them out, I
would like you to indicate whether you
agree or disagree with each. ___________
"The U.S. will allow people in this region to fashion their own political 
future as they see fit without direct U.S. influence."
   1 "1 Agree"
   2 "2 Disagree"
   3 "3 (DK)"
   4 "4 (Refused)";  */
recode wp14256 (3=.a) (4=.d) 
tab wp14256, gen(g_usa_view)
   
/*WP4834 Do you think violent conflict
between the Muslim and Western worlds
can be avoided or not?
      1 "1 Can be avoided"
   2 "2 Cannot be avoided"
   3 "3 Dont know"
   4 "4 Refuse";  */
recode wp4834 (3=.a) (4=.d)
tab wp4834, gen (g_muswest)
   
************************************
*      Political Grievance
************************************

   
/* WP111 Have you done any of the following in the past month? How about: Voiced your
opinion to a public official?
  1 "1 Yes"
   2 "2 No"
   3 "3 (DK)"
   4 "4 (Refused)";  */
 recode wp111 (3=.a) (4=.d) 
 tab wp111 , gen(g_voice_public_off)
 

 /* WP1417 In your opinion, how many people
in your country, if any, are afraid to openly
express their political views? (Read 1-4)
   1 "1 Most are afraid"
   2 "2 Many are afraid"
   3 "3 Some are afraid"
   4 "4 No one is afraid"
   5 "5 (DK)"
   6 "6 (Refused)"; */
   recode wp1417 (5=.a) (6=.d) 
   tab wp1417, gen(g_views_afraid)

   /* WP146 Is corruption widespread
throughout the government in (response in
Sa/WP5), or not?
   1 "1 Yes"
   2 "2 No"
   3 "3 (DK)"
   4 "4 (Refused)"; */
 recode wp146 (3=.a) (4=.d) 
  tab wp146, gen(g_corr_gov)
 
 
/*Is corruption widespread within businesses located in (country), or not?
1 "1 Yes"
   2 "2 No"
   3 "3 (DK)"
   4 "4 (Refused)"; */

recode wp145 (3=.a) (4=.d)
  tab wp145 , gen(g_corr_buss)

**********************************************
*       Financial well-being 
**********************************************

/*
- Are you satisfied or dissatisfied with your standard of living, all the things you can buy and do? (WP30)
- Right now, do you feel your standard of living is getting better or getting worse? (WP31)
- Right now, do you think that economic conditions in the city or area where you live, as a whole, are getting better or
getting worse? (WP88) */
  
 recode wp30 (3=.a) (4=.d)
 tab wp30, gen(g_std_liv)
 recode wp31 (5=.a) (4=.d)
 tab wp31 , gen(g_std_liv_fut)
 recode wp88 (5=.a) (4=.d)
 tab wp88 , gen(g_econ_cond_city)
   
   
/*wp40: Have there been times in the past twelve months when you did not have enough money
To buy food that you or your family needed  */
recode wp40 (3=.a) (4=.d)
tab wp40, gen(g_money_food)

/*wp43: Have there been times in the past twelve months when you did not have enough money
To provide adequate shelter or housing for you and your family */
recode wp43 (3=.a) (4=.d)
tab wp43, gen(g_money_shelter) 
   


************************************************
*        Religious Opinions
************************************************

 /*wp645: In general, which of these statements comes closest to your own point 
 of view? Sharia should be the only source, a source, not a source of legislation. 
   1 "1 Sharia must be the only source of legislation"
   2 "2 Sharia must be a source of legislation, but not the only source"
   3 "3 Sharia should not be a source of legislation"
   4 "4 (DK)"
   5 "5 (Refused)"
   6 "6 Do not know what Sharis means"; */
   
recode wp645 (4=.a) (5=.d) 
tab wp645, gen(g_sharia_leg)
   
  
  
  /*wp7462 how much do you agree
or disagree with the following statements?
You may use any number between 1 and 5
to make your rating. I always treat people of other rel faith with respect
  label define 
   1 "1 Strongly disagree"
   2 "2"
   3 "3"
   4 "4"
   5 "5 Strongly agree"
   6 "6 (DK)"
   7 "7 (Refused)"; */
   
  recode wp7462 (6=.a) (7=.d)
  tab wp7462, gen(g_respect_other_rel)  
  
   
    /*wp7464 how much do you agree
or disagree with the following statements?
You may use any number between 1 and 5
to make your rating. I wd not object to a person of diff religious faith moving next door
  label define 
   1 "1 Strongly disagree"
   2 "2"
   3 "3"
   4 "4"
   5 "5 Strongly agree"
   6 "6 (DK)"
   7 "7 (Refused)"; */
   
  recode wp7464 (6=.a) (7=.d)
  tab wp7464, gen(g_nhbor_other_rel)  
   
   
      /*wp7463 how much do you agree
or disagree with the following statements?
You may use any number between 1 and 5
to make your rating. Most religious faiths make a positive contribution to society
  label define 
   1 "1 Strongly disagree"
   2 "2"
   3 "3"
   4 "4"
   5 "5 Strongly agree"
   6 "6 (DK)"
   7 "7 (Refused)"; */
   
  recode wp7463 (6=.a) (7=.d)
  tab wp7463, gen(g_rel_pos_contr)  
  
     /*wp7466 how much do you agree
or disagree with the following statements?
You may use any number between 1 and 5
to make your rating. In the past year, i have learned st from smone of another religious faith
  label define 
   1 "1 Strongly disagree"
   2 "2"
   3 "3"
   4 "4"
   5 "5 Strongly agree"
   6 "6 (DK)"
   7 "7 (Refused)"; */
   
  recode wp7466 (6=.a) (7=.d)
  tab wp7466, gen(g_learned_other_rel) 
  
  
****************************************************
*       Gender Equality
****************************************************  
  
   /*wp1140 WP1140 Do you agree or disagree with the
following statements? Women and men
should have equal legal rights 
1 "1 Agree"
   2 "2 Disagree"
   3 "3 (DK)"
   4 "4 (Refused)";    */
   
 recode wp1140 (3=.a) (4=.d)
 tab wp1140, gen(g_women1_rts)
 
   
  /*WP1145 Do you agree or disagree with the
following statements? Women should be
allowed to hold any job for which they are
qualified outside the home
1 "1 Agree"
   2 "2 Disagree"
   3 "3 (DK)"
   4 "4 (Refused)";    */
   
 recode wp1145 (3=.a) (4=.d)
 tab wp1145, gen(g_women2_rts)  
   
   
/* WP1146 Do you agree or disagree with the
following statements? Women should be
able to hold leadership positions in the
cabinet and the national council  
    "1 Agree"
   2 "2 Disagree"
   3 "3 (DK)"
   4 "4 (Refused)";    */
   
recode wp1146 (3=.a) (4=.d)
tab wp1146, gen(g_women3_rts)



* ------------------------------------------------------------------------------

* Collapsing data to create country-year panel

collapse wp1220 INC_007 region1-g_women3_rts2  [pw=wgt], by(countrynew YEAR_CALENDAR)

* ------------------------------------------------------------------------------

*************************************
*       Renaming Variables
*************************************

rename YEAR_CALENDAR year
rename wp1220 g_age
rename INC_007 g_percapitainc
rename region1 g_region_europe
rename region2 g_region_formersoviet
rename region3 g_region_asia
rename region4 g_region_americas
rename region5 g_region_mena
rename region6 g_region_subafrica
rename g_gender1 g_male
rename g_gender2 g_female

*************************************
*       Labeling Variables
*************************************

foreach i of varlist g_region_europe - g_region_subafrica {
label variable `i' "region dummy"
}

label variable g_percapitainc "HH income per capita"
label variable g_age "age"

label variable g_civ1_viol1 "prop who never justify attacks on civilians"
label variable g_civ1_viol2 "prop who mildly never justify attacks on civilians"
label variable g_civ1_viol3 "prop who are indifferent to attacks on civilians"
label variable g_civ1_viol4 "prop who mildly justify attacks on civilians"
label variable g_civ1_viol5 "prop who always justify attacks on civilians"

label variable g_wtc_usa1 "prop who never justify 911 attacks"
label variable g_wtc_usa2 "prop who mildly never justify 911 attacks"
label variable g_wtc_usa3 "prop who are indifferent to 911 attacks"
label variable g_wtc_usa4 "prop who mildly justify 911 attacks"
label variable g_wtc_usa5 "prop who always justify 911 attacks"

label variable g_sacr_life1 "prop who never justify Sacrificing ones life for what one believes in"
label variable g_sacr_life2 "prop who mildly never justify Sacrificing ones life for what one believes in"
label variable g_sacr_life3 "prop who are indifferent to Sacrificing ones life for what one believes in"
label variable g_sacr_life4 "prop who mildly justify Sacrificing ones life for what one believes in"
label variable g_sacr_life5 "prop who always justify Sacrificing ones life for what one believes in"

label variable g_extreme_risk1 "prop who are willing to take any amount of extreme risk to get what you want"
label variable g_extreme_risk2 "prop who are not willing to take any amount of extreme risk to get what you want"

label variable g_peaceful1_means1 "oppressed groups can improve their situation through peaceful means alone"
label variable g_peaceful1_means2 "oppressed groups cannot improve their situation through peaceful means alone"

label variable g_mil_target_civ1 "prop who think it is never justified for military to target civilians"
label variable g_mil_target_civ2 "prop who think it is sometimes justified for military to target civilians"
label variable g_mil_target_civ3 "prop who say it depends ( military to target civilians)"

label variable g_civ2_viol1 "prop who never justify attacks on civilians"
label variable g_civ2_viol2 "prop who sometimes justify attacks on civilians"
label variable g_civ2_viol3 "prop who say it depends (attacks on civilians)"

label variable g_peaceful2_means1 "oppressed groups can improve their situation through peaceful means alone"
label variable g_peaceful2_means2 "oppressed groups cannot improve their situation through peaceful means alone"

label variable g_living_harmony1 "prop who never justify 'not living in harmony with those who do not share your opinion'"
label variable g_living_harmony2 "prop who mildly never justify 'not living in harmony with those who do not share your opinion'"
label variable g_living_harmony3 "prop who are indifferent to 'not living in harmony with those who do not share your opinion'"
label variable g_living_harmony4 "prop who mildly justify 'not living in harmony with those who do not share your opinion'"
label variable g_living_harmony5 "prop who always justify 'not living in harmony with those who do not share your opinion'"

label variable g_male "prop of males"
label variable g_female "prop of females"

*label variable g_age_cat1 "prop of youth (13-14)"
*label variable g_age_cat2 "prop of adult (25-64)"
*label variable g_age_cat3 "prop of old (65+)"

label variable g_poverty1 "prop who live on more than 2$ a day"
label variable g_poverty2 "prop who live on less than 2$ a day"

*label variable g_income_quintiles1 "prop of poorest 20%"
*label variable g_income_quintiles2 "prop of second 20%"
*label variable g_income_quintiles3 "prop of middle 20%"
*label variable g_income_quintiles4 "prop of fourth 20%"
*label variable g_income_quintiles5 "prop of richest 20%"

label variable g_residence1 "prop who live in rural area/farm"
label variable g_residence2 "prop who live in small town"
label variable g_residence3 "prop who live in large city"
label variable g_residence4 "prop who live in suburb"

label variable g_marital_status1 "prop who are single/never married"
label variable g_marital_status2 "prop who are married"
label variable g_marital_status3 "prop who are separated"
label variable g_marital_status4 "prop who are divorced"
label variable g_marital_status5 "prop who are widowed"
label variable g_marital_status6 "prop who have a domestic partner"

label variable g_children1 "prop of hh with children under age of 15"
label variable g_children2 "prop of hh with no children under age of 15"

label variable g_religiosity1 "prop who consider religion an imp part of their daily life"
label variable g_religiosity2 "prop who do not consider religion an imp part of their daily life"

label variable g_religion1 "prop of christians"
label variable g_religion2 "prop of muslims"
label variable g_religion3 "prop of hindus"
label variable g_religion4 "prop of buddhist"
label variable g_religion5 "prop of jews"
label variable g_religion6 "prop of secular/none"
label variable g_religion7 "prop of other religion"

label variable g_conf_relg_org1 "prop confident of religious organizations"
label variable g_conf_relg_org2 "prop not confident of religious organizations"

label variable g_emp_status1 "prop employed full time for an employer"
label variable g_emp_status2 "prop employed full time for self"
label variable g_emp_status3 "prop employed part time do not want full time"
label variable g_emp_status4 "prop unemployed"
label variable g_emp_status5 "prop employed part time want full time"
label variable g_emp_status6 "prop out of work force"

label variable g_educ_status1 "prop with primary education"
label variable g_educ_status2 "prop with secondary education"
label variable g_educ_status3 "prop with tertiary education"

label variable g_lifesat_present1 "prop who are suffering at present"
label variable g_lifesat_present2 "prop who are struggling at present"
label variable g_lifesat_present3 "prop who are thriving at present"

label variable g_lifesat_future1 "prop who place themselves as suffering in future"
label variable g_lifesat_future2 "prop who place themselves as struggling in future"
label variable g_lifesat_future3 "prop who place themselves as thriving in future"

label variable g_conf_police1 "prop who have confindence in local police"
label variable g_conf_police2 "prop who do not have confindence in local police"

label variable g_safeatnight1 "prop who feel safe walking alone at night"
label variable g_safeatnight2 "prop who do not feel safe walking alone at night"

label variable g_theft1 "prop who have had money or property stolen"
label variable g_theft2 "prop who have had no money or property stolen"

label variable g_landline1 "prop who have a landline telephone"
label variable g_landline2 "prop who do not have a landline telephone"
 
label variable g_mobile1 "prop who have a cellphone"
label variable g_mobile2 "prop who do not have a cellphone"

label variable g_tv1 "prop who have a tv"
label variable g_tv2 "prop who do not have a tv"

label variable g_internet1 "prop who have internet"
label variable g_internet2 "prop who do not have internet"

label variable g_freedom_media1 "media in the country has lot of freedom"
label variable g_freedom_media2 "media in the country do not have lot of freedom"

label variable g_com1_attach1 "prop satisfied with the city where they live"
label variable g_com1_attach2 "prop dissatisfied with the city where they live"

label variable g_com2_attach1 "prop likely to move from their city"
label variable g_com2_attach2 "prop unlikely to move from their city"

label variable g_com3_attach1 "prop who would recommend their city to a friend to live"
label variable g_com3_attach2 "prop who would not recommend their city to a friend to live"

label variable g_social1_wellbeing1 "prop who have relatives or friends to count on to help in times of trouble"
label variable g_social1_wellbeing2 "prop who do not have relatives or friends to count on to help in times of trouble"

label variable g_social2_wellbeing1 "prop who are satisfied with the opportunities to meet ppl and make friends in their city"
label variable g_social2_wellbeing2 "prop who are dissatisfied with the opportunities to meet ppl and make friends in their city"

label variable g_time_family1 "prop who spend on an avg day no time with their family and relatives"
label variable g_time_family2 "prop who spend on an avg day less than 1 hour with their family and relatives"
label variable g_time_family3 "prop who spend on an avg day 1-2 hours with their family and relatives"
label variable g_time_family4 "prop who spend on an avg day 3-5 hours with their family and relatives"
label variable g_time_family5 "prop who spend on an avg day 6-8 hours with their family and relatives"
label variable g_time_family6 "prop who spend on an avg day 9 hours or more with their family and relatives"

label variable g_time_friends1 "prop who spend on an avg day no time with their friends"
label variable g_time_friends2 "prop who spend on an avg day less than 1 hour with their friends"
label variable g_time_friends3 "prop who spend on an avg day 1-2 hours with their friends"
label variable g_time_friends4 "prop who spend on an avg day 3-5 hours with their friends"
label variable g_time_friends5 "prop who spend on an avg day 6-8 hours with their friends"
label variable g_time_friends6 "prop who spend on an avg day 9 hours or more with their friends"

label variable g_conf_military1 "prop who have confidence in the military"
label variable g_conf_military2 "prop who do not have confidence in the military"

label variable g_conf_court1 "prop who have confidence in the courts"
label variable g_conf_court2 "prop who have no confidence in the courts"

label variable g_conf_gov1 "prop who have confidence in the government"
label variable g_conf_gov2 "prop who have no confidence in the government"

label variable g_conf_election1 "prop who have confidence in the honesty of elections"
label variable g_conf_election2 "prop who have no confidence in the honesty of elections"

label variable g_freedom_life1 "prop who are satisfied with freedom to choose what to do with their life"
label variable g_freedom_life2 "prop who are dissatisfied with freedom to choose what to do with their life"

label variable g_good_minorities1 "prop who consider their city a good place to live for raacial and ethnic minorities"
label variable g_good_minorities2 "prop who consider their city is not a good place to live for raacial and ethnic minorities"

label variable g_good_lgbt1 "prop who consider their city a good place to live for lgbt people"
label variable g_good_lgbt2 "prop who consider their city is not a good place to live for lgbt people"

label variable g_good_immigrants1 "prop who consider their city a good place to live for immigrants"
label variable g_good_immigrants2 "prop who consider their city is not a good place to live for immigrants"

label variable g_sat_roads1 "prop who are satisfied with the roads and highways"
label variable g_sat_roads2 "prop who are dissatisfied with the roads and highways"

label variable g_sat_pubtrans1 "prop who are satisfied with public transport"
label variable g_sat_pubtrans2 "prop who are dissatisfied with public transport"

label variable g_sat_air1 "prop who are satisfied with quality of air in their city"
label variable g_sat_air2 "prop who are dissatisfied with quality of air in their city"

label variable g_sat_water1 "prop who are satisfied with quality of water in their city"
label variable g_sat_water2 "prop who are dissatisfied with quality of water in their city"

label variable g_sat_housing1 "prop who are satisfied with avl of good affordable housing"
label variable g_sat_housing2 "prop who are dissatisfied with avl of good affordable housing"

label variable g_sat_schools1 "prop who are satisfied with educational system or schools"
label variable g_sat_schools2 "prop who are dissatisfied with educational system or schools"

label variable g_sat_healthcare1 "prop who are satisfied with avl of good quality healthcare"
label variable g_sat_healthcare2 "prop who are dissatisfied with avl of good quality healthcare"

label variable g_usa_view1 "agree that U.S. will allow people in this region to fashion their own political future as they see fit without direct U.S. influence"
label variable g_usa_view2 "disagree that U.S. will allow people in this region to fashion their own political future as they see fit without direct U.S. influence"

label variable g_muswest1 "prop who think violent conflict btw muslim and western worlds can be avoided"
label variable g_muswest2 "prop who think violent conflict btw muslim and western worlds cannot be avoided"

label variable g_voice_public_off1 "prop who have voiced their opinion to public officials in the past month"
label variable g_voice_public_off2 "prop who have not voiced their opinion to public officials in the past month"

label variable g_views_afraid1 "most ppl are afraid to openly express their political views"
label variable g_views_afraid2 "many ppl are afraid to openly express their political views"
label variable g_views_afraid3 "some ppl are afraid to openly express their political views"
label variable g_views_afraid4 "no one is afraid to openly express their political views"

label variable g_corr_gov1 "prop who think corruption is widespread throughout the govt."
label variable g_corr_gov2 "prop who think corruption is not widespread throughout the govt."

label variable g_corr_buss1 "prop who think corruption is widespread within businesses"
label variable g_corr_buss2 "prop who think corruption is not widespread within businesses"

label variable g_std_liv1 "prop who are satisfied with their std of living"
label variable g_std_liv2 "prop who are dissatisfied with their std of living"

label variable g_std_liv_fut1 "prop who think their std of living will get better"
label variable g_std_liv_fut2 "prop who think their std of living will remain same"
label variable g_std_liv_fut3 "prop who think their std of living will get worse"

label variable g_econ_cond_city1 "prop who think economic conditions in their city are getting better"
label variable g_econ_cond_city2 "prop who think economic conditions in their city are the same"
label variable g_econ_cond_city3 "prop who think economic conditions in their city are getting worse"

label variable g_money_food1 "prop who had enough money to buy food"
label variable g_money_food2 "prop who did not have enough money to buy food"

label variable g_money_shelter1 "prop who had enough money to provide adequate shelter or housing"
label variable g_money_shelter2 "prop who did not have enough money to provide adequate shelter or housing"

label variable g_sharia_leg1 "sharia must be the only source of legislation"
label variable g_sharia_leg2 "Sharia must be a source of legislation, but not the only source"
label variable g_sharia_leg3 "Sharia should not be a source of legislation"
label variable g_sharia_leg4 "do not know what Sharia means"

label variable g_respect_other_rel1 "strongly disagree-I always treat people of other rel faith with respect"
label variable g_respect_other_rel2 "mildly disagree-I always treat people of other rel faith with respect"
label variable g_respect_other_rel3 "indifferent-I always treat people of other rel faith with respect"
label variable g_respect_other_rel4 "mildly agree-I always treat people of other rel faith with respect"
label variable g_respect_other_rel5 "strongly agree-I always treat people of other rel faith with respect"

label variable g_nhbor_other_rel1 "strongly disagree-I wd not object to a person of diff religious faith moving next door"
label variable g_nhbor_other_rel2 "mildly disagree-I wd not object to a person of diff religious faith moving next door"
label variable g_nhbor_other_rel3 "indifferent-I wd not object to a person of diff religious faith moving next door"
label variable g_nhbor_other_rel4 "mildly agree-I wd not object to a person of diff religious faith moving next door"
label variable g_nhbor_other_rel5 "strongly agree-I wd not object to a person of diff religious faith moving next door"

label variable g_rel_pos_contr1 "strongly disagree-Most religious faiths make a positive contribution to society"
label variable g_rel_pos_contr2 "mildly disagree-Most religious faiths make a positive contribution to society"
label variable g_rel_pos_contr3 "indifferent-Most religious faiths make a positive contribution to society"
label variable g_rel_pos_contr4 "mildly agree-Most religious faiths make a positive contribution to society"
label variable g_rel_pos_contr5 "strongly agree-Most religious faiths make a positive contribution to society"

label variable g_learned_other_rel1 "strongly disagree-I have learned st from smone of another religious faith"
label variable g_learned_other_rel2 "mildly disagree-I have learned st from smone of another religious faith"
label variable g_learned_other_rel3 "indifferent-I have learned st from smone of another religious faith"
label variable g_learned_other_rel4 "mildly agree-I have learned st from smone of another religious faith"
label variable g_learned_other_rel5 "strongly agree-I have learned st from smone of another religious faith"

label variable g_women1_rts1 "Agree- women and men should have equal legal rts"
label variable g_women1_rts2 "Disagree- women and men should have equal legal rts"

label variable g_women2_rts1 "Agree- Women should be allowed to hold any job for which they are qualified"
label variable g_women2_rts2 "Disagree- Women should be allowed to hold any job for which they are qualified"

label variable g_women3_rts1 "Agree- Women should be able to hold leadership positions in the cabinet"
label variable g_women3_rts2 "Disagree- Women should be able to hold leadership positions in the cabinet"

*----------------------------------------------------------------------------------------------------------------------------------


* Adding countries that are in WDI but not in gallup

insobs 55, before(1)
 replace countrynew = "Equatorial Guinea" in 1/11
 replace year = 2005 in 1
 replace year = year[_n-1]+1  in 2/11

 replace countrynew = "Eritrea" in 12/22
 replace year = 2005 in 12
 replace year = year[_n-1]+1  in 13/22

 replace countrynew = "Gambia, The" in 23/33
 replace year = 2005 in 23
 replace year = year[_n-1]+1  in 24/33

 replace countrynew = "Guinea-Bissau" in 34/44
 replace year = 2005 in 34
 replace year = year[_n-1]+1  in 35/44

 replace countrynew = "North Korea" in 45/55
 replace year = 2005 in 45
 replace year = year[_n-1]+1  in 46/55


 * Creating numeric variable for countries

sort countrynew, stable
encode countrynew, gen(ctry)

sort ctry year

save "${outdir}/gallup.dta", replace

log close

